package com.czxy.service;

import com.czxy.dao.PersonMapper;
import com.czxy.domain.Person;
import com.czxy.domain.PersonVo;
import com.czxy.utils.MyBatisUtils;

import java.util.List;

public class PersonService {


    //动态查询

    public  List<Person> findPersonInfo(Person person){
        PersonMapper mapper = MyBatisUtils.getMapper(PersonMapper.class);
        List<Person> list = mapper.findPersonInfo(person);
        MyBatisUtils.close();
        return list;

    }








    public  List<Person> findPVo(PersonVo vo){
        PersonMapper mapper = MyBatisUtils.getMapper(PersonMapper.class);
        List<Person> list = mapper.findInfo(vo);
        MyBatisUtils.close();
        return list;
    }












    public List<Person> findSex (Person person){

        PersonMapper mapper = MyBatisUtils.getMapper(PersonMapper.class);

        List<Person> list = mapper.findSex(person);


        MyBatisUtils.close();

        return list;

    }












    public void delById(Integer uid){

        PersonMapper mapper = MyBatisUtils.getMapper(PersonMapper.class);

        mapper.delById(uid);

        MyBatisUtils.commitAndClose();


    }

    public void del(Person person){

        PersonMapper mapper = MyBatisUtils.getMapper(PersonMapper.class);

        mapper.del(person);

        MyBatisUtils.commitAndClose();


    }


















    public  void  update(Person person){

        PersonMapper mapper = MyBatisUtils.getMapper(PersonMapper.class);
        mapper.update(person);
        MyBatisUtils.commitAndClose();

    }



    public  void  add (Person person){
        PersonMapper mapper = MyBatisUtils.getMapper(PersonMapper.class);
        mapper.add(person);
        MyBatisUtils.commitAndClose();
    }


    public List<Person> findPersonByUid(Integer uid){

        PersonMapper mapper = MyBatisUtils.getMapper(PersonMapper.class);

        List<Person> list = mapper.findPersonById(uid);

        MyBatisUtils.close();

        
        return list;
    }


    public List<Person> findAll(){

        PersonMapper mapper = MyBatisUtils.getMapper(PersonMapper.class);

        List<Person> list = mapper.findAll();

        MyBatisUtils.close();
        return list;
    }
}
